<%-- 
    Document   : muahang
    Created on : 02-10-2011, 19:35:41
    Author     : Mr-Nguyen
--%>

<%@page import="DatabasePOJO.user"%>
<%@page import="DAO.sanphamDAO"%>
<%@page import="DatabasePOJO.sanpham"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<script type="text/javascript">
    	function Change(){
		var sl = document.getElementById("cmbsl");
		var gia = document.getElementById("txtgiaban");
		var giatong = document.getElementById("txtgiatong");
		var tonggia = document.getElementById("txttonggia");
		giatong.value = sl.value * gia.value;
		tonggia.value = giatong.value;
	}
</script>
<%
    user us = new user();
    us.setTenDangNhap("Guest");
    us.setSoDuTaiKhoan("0");
    if(session.getAttribute("login")!=null)
        us = (user)session.getAttribute("login");
    String masp = request.getParameter("MaspMua");
    sanpham spMua = sanphamDAO.getSanPham(masp);
    if(request.getParameter("button") != null)
    {
        String giasp = request.getParameter("txttonggia");
        if(Integer.parseInt(us.getSoDuTaiKhoan()) < Integer.parseInt(giasp))
       {%>
           <script type="text/javascript">
               alert("Số dư tài khoảng của bạn không đủ để thực hiện giao dịc này");
           </script>
        <%}
    }
%>
<form id="form1" name="form1" method="post" action="index.jsp?Action=Mua&MaspMua=<%= masp %>" onsubmit="return testfrom();">
<table width="100%" border="0" bgcolor="#FFD7D7">
    <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
    </tr>
    <tr style="background-image:url(Images/backngang.jpg)">
            <td>Chào : <%= us.getTenDangNhap() %></td>
            <td>Số du tài khoảng: <%= us.getSoDuTaiKhoan() %>VNĐ</td>
          </tr>
          <tr>
            <td height="40" colspan="2" align="center" valign="middle">THÔNG TIN ĐƠN HÀNG</td>
            </tr>
          <tr>
            <td height="125" colspan="2" valign="top">
                 
            <table width="100%" border="0" bordercolor="#FF0000">
              <tr style="background-image:url(Images/backngang.jpg)">
                <td width="10%">STT</td>
                <td width="56%">Thông tin chi tiết</td>
                <td width="10%">SLượng</td>
                <td width="12%">Giá bán</td>
                <td width="12%">Tổng giá</td>
              </tr>
              <tr>
                <td bgcolor="#99FFFF" align="center" >1</td>
                <td bgcolor="#FFFFFF">
                    <a href="index.jsp?Action=chitiet&MaSanPham=<%= spMua.getMaSanPham()%>"> <%=spMua.getTitle()%> </a>                   
                </td>
                <td align="right" valign="top">
                   
                  <select name="cmbsl" id="cmbsl"  style="width:65px" onchange="Change();">
                    <option value="1"> 1 </option>
                    <option value="2"> 2 </option>
                    <option value="3"> 3 </option>
                    <option value="4"> 4 </option>
                    <option value="5"> 5 </option>
                    <option value="6"> 6 </option>
                  </select>
                </td>
                <td align="right" valign="top" bgcolor="#FFFFFF">
                    <input name="txtgiaban" id ="txtgiaban" type="text" value="<%= spMua.getGiaKhuyenMai() %>" size="10" readonly="true" />
                </td>
                <td align="right" valign="top">
                <input name="txtgiatong" id="txtgiatong" type="text" value="<%= spMua.getGiaKhuyenMai() %>" size="10" readonly="true" />
                </td>
              </tr>
              <tr style="background-image:url(Images/backlogo.gif)">
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td colspan="2" align="right" valign="top">
                Tổng:<input name="txttonggia" id="txttonggia" type="text" value="<%= spMua.getGiaKhuyenMai() %>" size="10" readonly="true" />
                vnđ
                </td>
                </tr>
            </table>
                 
                 </td>
            </tr>
          <tr>
            <td  background="Images/backmenu.gif">Thanh toán trực tuyến</td>
             <td align="right" background="Images/backmenu.gif">
                 <input type="submit" name="button" id="btn" value="Hoàn tất đơn hàng"  style="background-image:url(Images/backngang.jpg)" onclick="onclickbtn()"/>
             <input name="btn" type="button" value="L&acirc;&#803;p phi&ecirc;&#769;u giao ha&#768;ng t&acirc;&#803;n nha&#768;" style="background-image:url(Images/backngang.jpg)" onclick="anhien();"/>
             </td>
            </tr>
          <tr>
            <td colspan="2">
                <jsp:include page="phiuegiaohang.jsp"/>
            </td>
          </tr>
</table>
</form>